#!/usr/bin/env python3
# Licensing : see licensing directory
import os

def phase0 ():
    """This phase looks up for environment and arguments."""
    print ("\nPhase #0: Arguments")
    base_dir = os.getcwd()              # Get current directory from os
    choice1 = input ("\tCurrent directory is '"+base_dir+"'. Do you want to proceed ? (y/n) ")
    
    while (1):             # Loop until user has typed a correct answer
        if (choice1 == 'n'):
            base_dir = input ("\tType the source directory path please : ")
            print ("\tChanging to '"+base_dir+"'")
            try:
                os.chdir(base_dir)          # Changing to the user typed dir
            except:
                print ("\tError: Path not reachable")
                choice1 = 'n'    
            else:
                print ("\tSuccessfully changed to '"+os.getcwd()+"'")
                base_dir = os.getcwd()
                choice1 = input("\tBase directory is '"+base_dir+"'. Do you want to proceed ? (y/n) ")
        elif (choice1 == 'y'):
            return base_dir
        else:
            print ("\tError: Bad answer")
            choice1 = input ("\tCurrent directory is '"+base_dir+"'. Do you want to proceed ? (y/n) ")
